

public class PrintExample {
    public static void main(String[] args) {
        // comment/uncomment the following lines to test the
        // sequential or the concurrent version of the code

        sequentialPrint();
        //concurrentPrint();
    }

    public static void concurrentPrint() {
        class PrintTask implements Runnable {
            char c;
            PrintTask(char c) {
                this.c = c;
            }

            public void run() {
                for (int j = 0; j < c-'A'+1; j++) {
                    System.out.print(c);
                }
                System.out.println();
            }
        }

        for (char c = 'A'; c < 'P'; c++) {
            new Thread(new PrintTask(c)).start();
        }
    }


    public static void sequentialPrint() {
        for (char c = 'A'; c < 'P'; c++) {
            for (int j = 0; j < c-'A'+1; j++) {
                System.out.print(c);
            }
            System.out.println();
        }
    }
}
